#include<iostream>

using namespace std;

int N,M,high=0,ORD[10000],ans[10000],add[4],ord[]={24,6,2,1,0},i;
int main(){
    scanf("%d\n%d",&N,&M);
    for ( i = 0; i < N; i++)
    {
        scanf("%d",&ORD[i]);
    }
    for ( i = 0; i < 4; i++)
    {
        add[i]=M/ord[i];
        if(add[i]&&!high) high = 5-i;
        M%=ord[i];
    }
    memcpy(ord,&ORD[N-high],high);

    
    

    return 0;
}
